<?php
/**
* test widget
*/
class productWidget extends CWidget
{    
    public function init()
    {
        //当视图中执行$this->beginWidget()时候会执行这个方法
        //可以在这里进行查询数据操作
    }
 
    public function run()
    {
        $condition = new CDbCriteria();
        $condition->addCondition("recommend='是'");
        $condition->addCondition("t.status='正常'");
        $condition->with = 'class';
        $condition->order = 't.hot desc';
        $condition->limit = 2;
        $rowTable = Product::model()->findAll($condition);
        unset($condition);
        $this->render('product',array(
            'rowTable'=>$rowTable,
        ));
    }
}
?>